package com.diandi.signature.controller.cainfo;

import com.alibaba.fastjson.JSONObject;
import com.diandi.signature.signatureca.CADataService;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.Map;

/**
 * Created by mxp on 2017/12/15.
 */
@Controller
@RequestMapping(value = "ca")
public class ViewCAInfoController {
    private Logger logger = LoggerFactory.getLogger(ViewCAInfoController.class);

    @Autowired
    private CADataService caDataService;

    @RequestMapping(value = "/index")
    public String index(){
        return "ca/viewCA";
    }

    @RequestMapping(value = "/queryList")
    @ResponseBody
    public String queryList(
            @RequestParam(required = false)String step,
            @RequestParam(required = false)String userId,
            @RequestParam(defaultValue = "0")Integer page,
            @RequestParam(defaultValue = "10")Integer rows
    ){

        Map<String, Object> returnMap = null;

        if (StringUtils.isNotBlank(step)){
            returnMap = caDataService.queryList(userId, page, rows);
        }

        return JSONObject.toJSONString(returnMap);
    }
}